package shiyl.use.any.helloworld.reflect;

import lombok.Data;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Data
public class Channel {

    String  whichChannel;

    public Channel ( String whichChannel){
        this.whichChannel = whichChannel;
    }

    public Collection<Response> sendProposalTransaction(TransactionRequest request, List<Peer> peers){

        Collection<Response> responses = new ArrayList<>();

        // 模拟向peer逐个发送交易
        for( Peer peer : peers  ){

            // 直接构造一个响应，模拟已经处理并获得返回结果
            Response rsp = new Response() ;
            rsp.setPeer(peer);
            rsp.setResult(this.whichChannel+" 调用 "+ peer + " 处理 " + request.toString());
            responses.add(rsp);
        }

        return responses ;
    }
}
